package org.example.projecttwo.controller.user;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.example.projecttwo.common.Result;
import org.example.projecttwo.entity.user.UserStatistics;
import org.example.projecttwo.service.Iuser.IUserStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/statistics")
@Tag(name = "用户统计管理", description = "用户统计数据管理")
public class UserStatisticsController {

    @Autowired
    private IUserStatisticsService userStatisticsService;

    @GetMapping("/current")
    @Operation(summary = "获取当前用户统计信息", description = "获取当前登录用户的统计数据 -- 个人信息")
    public Result<UserStatistics> getCurrentUserStatistics() {
        return Result.success(userStatisticsService.getCurrentUserStatistics());
    }

    @GetMapping("/{userId}")
    @Operation(summary = "获取用户统计信息", description = "根据用户ID获取指定用户的统计数据 -- 用户管理")
    public Result<UserStatistics> getUserStatistics(@PathVariable Long userId) {
        return Result.success(userStatisticsService.getUserStatistics(userId));
    }

}